<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use Gregwar\Captcha\CaptchaBuilder;
use Illuminate\Support\Facades\Session;

class CodeController extends Controller{
    public function captcha($id)
    {
    $builder = new CaptchaBuilder();
    $builder->build(150,32);
//获取验证码内容
    $phrase = $builder->getPhrase();
    Session::flash('mikcaptcha',$phrase);
    //把内容存入session
    //Session::flash('milkcaptcha', $phrase); //存储验证码
    ob_clean(); //清除缓存
    return response($builder->output())->header('Content-type','image/jpeg'); //把验证码数据以jpeg图片的格式输出
  }
}